<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="sun.applet.resources.MsgAppletViewer_it"%>
<%@page import="utility.connections"%><html>
<script type="text/javascript" src="../js/immagini.js"></script>
<link href="../../layout.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
<!--
.style1 {color: #000000}
.style2 {
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
<head>

<jsp:useBean id="clsConn" scope="session" class="utility.connections"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>ELENCO BENI INVENTARIATI</title>

</head>

<body>
<table width="1381" height="422" border="0" align="center">
  <tr>
    <td width="953" align="center" valign="middle"></td>
  </tr>
  <tr>
    <td height="257" align="center" valign="top"><table width="100%" border="0">
      <tr>
        <td align="center"><div align="left">
          <p class="style3">
          
          <%  
		
			if (session.getAttribute("user")==null)
			response.sendRedirect("loginerr.jsp");
			
			else
			{
	
			String user = session.getAttribute("user").toString();
			String type = session.getAttribute("type").toString();
			String matr = session.getAttribute("matricola").toString();
			String nome = session.getAttribute("nome").toString();
			String cogn = session.getAttribute("cognome").toString();
			}
		%>
		  </p>
        </div></td>
        </tr>
     <tr>
     <div align="left">
   	</div>
   	</tr>
      <tr>
        <td class="style1"><p align="center" class="style2">Elenco completo dei beni inventariati   </p></td>
        </tr>
      <tr>
        <td class="style1"><div align="center"><input type="button" value="INDIETRO" onclick="location.href='../hamm.jsp'"/></div></td>
        </tr>
      <tr>
        <td class="style1"><div align="center">
          <table width="100%" cellpadding="2" cellspacing="0" bordercolor="#000000" style="border:1px solid;">
            <tr>
              <td width="3%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center" ><span class="style1">PROG</span></div></td>
              <td width="5%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=1">N.I.G.</a></div></td>
              <td width="5%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=2">N.I.S.</a></div></td>
              <td width="5%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=3">IMPORTO</a></div></td>
              <td width="7%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=4">DATA ACQ.  </a></div></td>
              <td width="7%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=5">GARANZIA</a></div></td>
              <td width="6%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=6">ATT. </a></div></td>
              <td width="6%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=7">SCAD.. </a></div></td>
              <td width="5%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=8">CONF.</a></div></td>
              <td width="3%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=9">OBS.</a></div></td>
              <td width="11%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=10">SOTTOCAT.</a></div></td>
              <td width="11%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=11">FORNITORE</a></div></td>
              <td width="4%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=12">TARGH.</a></div></td>
              <td width="22%" bordercolor="#333333" bgcolor="#FFFF99" class="style3" style="border:1px solid;"><div align="center"><a href="elenco_beni_inventariati.jsp?order=13">DESCRIZIONE</a></div></td>
            </tr>
			
			

<%! String user, matricola, codicefiscale, nome, cognome; 
	Connection conn;
	Statement  st;
	ResultSet  rs;
%>
<%
				
				user = session.getAttribute("user").toString().toLowerCase();
				conn=connections.getConnection();
				st=connections.getStatement();
				int order = Integer.parseInt(request.getParameter("order"));
				String qry = "SELECT B.NUMEROINVENTARIOGENERICO,B.NUMEROINVENTARIOSERIALE,TO_CHAR(B.IMPORTO,'999,999,999.99'),TO_CHAR(B.DATAACQUISTO,'DD/MM/YYYY')," + 
				             "B.GARANZIA,TO_CHAR(B.DATAATTIVAZIONE,'DD/MM/YYYY'),TO_CHAR(B.DATASCADENZA,'DD/MM/YYYY'),B.CONFORME," + 
				             "B.OBSOLETO,SC.NOME AS SOTTOCATEGORIA,F.NOMEORGANIZZAZIONE AS FORNITORE,B.TARGHETTA,B.DESCRIZIONE " + 
				             "FROM BENE B, SOTTOCATEGORIABENE SC, FORNITORE F " + 
				             "WHERE SC.CODICE=B.SOTTOCATEGORIABENE AND F.PARTITAIVA=B.FORNITORE ORDER BY " + order;
				
				ResultSet rs = st.executeQuery(qry);
				int i=0;
				
				if(rs.isBeforeFirst()&&rs.isAfterLast())
				{
					//Avvisare che non ci sono record!!!!
				}
				else
				{
					while (rs.next())
					{
						String color;
	              		String bordercell;
	              		
	              		i++;
	              		
	              		if (i%2==0)
	              		{
	              			color ="\"#E0E0E0\"";
	              			bordercell="style=\"border:1px solid;\";";
	              		}
	              		else
	              		{
	              			color = "\"#EFFFEF\"";
	              			bordercell="style=\"border:1px solid;\";";
	              		}
	              		
	              		out.println("<tr>");
	              		out.println("<td align=\"right\""+bordercell+" bordercolor=\"#555555\" bgcolor = "+color+ ">" + i + "</td>"); //prog.
	              		for(int col=1;col<14;col++)
	              		{
	              			if (col==5||col==8||col==9||col==12)
	              			{
	              				String chk= "";
	              				if (rs.getString(col).equals("1")) chk = "checked"; else chk="";
	              				out.println("<td align=\"center\""+bordercell+" bordercolor=\"#555555\" bgcolor = "+color+ "><input type = \"checkbox\" " + chk + " disabled></td>");
	              			}
	              			else
	              			{
	              				String alignment="";
	              				if(col==4||col==6||col==7)
	              					alignment="center";
	              				else
	              					alignment="right";
	              				out.println("<td align=\""+alignment+"\""+bordercell+" bordercolor=\"#555555\" bgcolor = "+color+ "><span class=\"style1\">" + rs.getString(col)+ "</span></td>");
	              			}
	              		}
	              		out.println("</tr>");
					}	
				}
				
				rs.close();
				st.close();
             %>
          </table>
        </div></td>
        </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
